package LeetCode.LC118;

import java.util.ArrayList;
import java.util.List;

/**
 * @author corn
 * @create 2020-11-09-23:34
 */
public class SolutionTest {
    public static void main(String[] args) {
        Solution solution = new Solution();
        List<List<Integer>> generate = solution.generate(6);
        System.out.println(generate.toString());
    }
}

class Solution{
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> lists = new ArrayList<List<Integer>>();
        if(numRows == 0){
            return lists;
        }
        for(int i = 0; i < numRows; i++){
            List<Integer> list = new ArrayList<>();
            int size = i + 1;
            for(int j = 0; j < size; j++){
                if(j == 0){
                    list.add(1);
                    if(size == 1){
                        lists.add(list);
                    }
                }else if(j == size - 1){
                    list.add(1);
                    lists.add(list);
                }else{
                    list.add(lists.get(i - 1).get(j - 1) + lists.get(i - 1).get(j));
                }
            }
        }
        return lists;
    }
}
